package String.api;

import java.nio.charset.StandardCharsets;
import java.sql.SQLOutput;

public class StringTest04 {
    public static void main(String[] args) {
        //equalsIgnoreCase比较字符串，忽略大小写
        System.out.println("abc".equalsIgnoreCase("ABC"));
        String s1 = "abc";
        //getBytes将字符串转化为哦字节数组
        System.out.println(s1.getBytes(StandardCharsets.UTF_8));//[B@1540e19d
        //hashcode返回这个字符的哈希码
        System.out.println(s1.hashCode());//96354
        //indexOf(String str)
        //查找字符串对应的位置
        String s2 = "hellowrod";
        System.out.println(s2.indexOf("h"));
        System.out.println(s2.indexOf("w"));
        System.out.println(s2.indexOf("d"));

        int[] a = {1, 2, 3};
        //打印数组的长度，3 length是数组的属性
        System.out.println(a.length);
        //length获取字符串的长度，是函数
        System.out.println(s2.length());
        String s3 = "";
        System.out.println(s3.length());
        String s4 = null;
        //System.out.println(s4.length());//NullPointerException

        //isEmpty判断字符串是否为空 length为0
        System.out.println(s3.isEmpty());
        System.out.println(s2.isEmpty());
        //lastIndexOf 获取某个字符最后出现的索引位置
        String s5 = "helloworld";
        System.out.println(s5.indexOf("o"));
        System.out.println(s5.lastIndexOf("o"));









    }
}
